package org.aceor.mddal.client.jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * Created by lxue on 16/4/5.
 */
public interface ConnectionManager {
    /**
     * 是否是自动提交
     *
     * @return
     */
    public boolean getAutoCommit() throws SQLException;

    /**
     *
     * @param dbIndex
     * @return
     */
    Connection getConnection(String dbIndex) throws SQLException;

    /**
     *
     * @param dbIndex
     * @throws SQLException 如果关闭时发生了异常会直接抛出 需要被显示的catch住
     */
    void tryClose(String dbIndex) throws SQLException;

    /**
     * 获取代理的连接
     *
     * @return
     */
    Connection getProxyConnection();

    /**
     * 移除当前statement
     *
     * @param statement
     */
    void removeCurrentStatement(Statement statement);

    /**
     * 是否包含对应的ds
     * @param dbIndex
     * @return
     */
    boolean containDBIndex(String dbIndex);
}
